|
|
|
|
|
|
|
leads to confusion between the two. The distinction between the two is a relic of C++ programming, with the separate header and implementation files that map to one logical class. For Visual Basic, a class interface and implementation are stored in one file, so there is no real distinction. Thus, a subsystem of five class files maps directly to a category of five classes. For simplicity, I'll use the term subsystem. |
|
|
|
|
|
|
|
|
In technical terms, a subsystem is a physical group of class modules (physical meaning class files). A more robust meaning is that each class in the group plays a role in providing an expected behavioral response to a client of the subsystem. |
|
|
|
|
|
|
|
|
Subsystems communicate with one another through public interface classes. Referring again to Listing 4.1, assume that you have a subsystem called AccountManagement. Both theDeposit and theBasicPersonalCheckingAccount are objects in it. The theDeposit object could easily be a public interface class because it played a similar role as user interface controller earlier. Any needs of a client subsystem to have the AccountManagement subsystem to handle deposits would be routed through theDeposit. |
|
|
|
|
|
|
|
|
Identifying Technical Constraints of the Implementation Environment |
|
|
|
|
|
|
|
|
Because Visual Basic still doesn't enable you to fully implement every pillar of object-oriented programming, there are some notions you'll need to keep in mind. Along with these notions, I'll discuss some solutions. |
|
|
|
|
|
|
|
|
Visual Basic doesn't support implementation inheritance. This is a fancy sentence that means that the private members of class A cannot be inherited by class B. However, Visual Basic does support limited interface inheritance, which means that class B can inherit the public members of class A. I say limited because class B cannot inherit the public members that class A inherits from another class. The inheritance of public members in Visual Basic is done via the Implements keyword. This choice of wording might confuse some people. The keyword Implements doesn't imply implementation inheritance. It facilitates interface inheritance. |
|
|
|
|
|
|
|
|
In any event, implementation inheritance can be replaced in most cases with delegation. Whole books have been written about delegation, but the idea, as explained briefly on Day 3, is that object A delegates some or all of its behavior to object B. The Account class used the CheckingAccountHistoryInfo class to verify a customer's checking account history. Hence, the Account class instance (theAccount) used the CheckingAccountHistoryInfo class instance (theCheckingAccountHistoryInfo) as follows: |
|
|
|
|
|